home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / CPPLMEN9.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  12.7 KB  |  402 lines

  1. /*****************************************************************************/
  2. /*       (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved         */
  3. /*****************************************************************************/
  4. /*    This source-code is NOT public domain nor Freeware, this is part of    */
  5. /*              'The C Programming Package' which is Shareware.              */
  6. /*   If you use this code, please register and get a free Full-VGA version   */
  7. /*****************************************************************************/
  8.                             /*----------------*
  9.                              *   CPPLMEN9.C   *
  10.                              * Menu manager9  *
  11.                              * Configuration  *
  12.                              *  environment   *
  13.                              *----------------*/
  14.  
  15.  /* Included Files */
  16.  # include <stdio.h>
  17.  # include <io.h>
  18.  # include <dos.h>
  19.  # include <fcntl.h>
  20.  # include <bios.h>
  21.  # include <stdlib.h>
  22.  # include <conio.h>
  23.  
  24.  /* Global Variables */
  25.  extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu9;
  26.  extern int colour1,colour2,colour3,colour4,colour5,soundvar,return1;
  27.  extern unsigned char c0,c1,trashcan[];
  28.  
  29.  /*----------------------*
  30.   * CHOICE DISPLAY HELP9 *
  31.   *----------------------*/
  32.   void choice_display_help9()
  33.     {
  34.       /* We display the help that concerns the line on */
  35.       /* which is the menu cursor (in red).            */
  36.       if(menu9==1){
  37.     /*  */
  38.         display_help("CONFIGUR",90,2,1);     restore_help_screen();
  39.       }
  40.       if(menu9==2){
  41.     /*  */
  42.         display_help("CONFIGUR",91,3,1);     restore_help_screen();
  43.       }
  44.       if(menu9==3){
  45.     /*  */
  46.         display_help("CONFIGUR",92,4,1);     restore_help_screen();
  47.       }
  48.       if(menu9==4){
  49.     /*  */
  50.         display_help("CONFIGUR",93,5,1);     restore_help_screen();
  51.       }
  52.       if(menu9==5){
  53.     /*  */
  54.         display_help("CONFIGUR",94,6,1);     restore_help_screen();
  55.       }
  56.       if(menu9==6){
  57.     /*  */
  58.         display_help("CONFIGUR",95,7,1);     restore_help_screen();
  59.       }
  60.       if(menu9==7){
  61.         /* available */
  62.         display_help("CONFIGUR",96,8,1);     restore_help_screen();
  63.       }
  64.       if(menu9==8){
  65.     /*  */
  66.         display_help("CONFIGUR",97,9,1);     restore_help_screen();
  67.       }
  68.       if(menu9==9){
  69.     /*  */
  70.         display_help("CONFIGUR",98,10,1);     restore_help_screen();
  71.       }
  72.       if(menu9==10){
  73.         /* quit to DOS */
  74.         display_help("CONFIGUR",99,11,1);    restore_help_screen();
  75.       }
  76.     }
  77.  /*----------------*
  78.   * GET THE MOUSE9 *
  79.   *----------------*/
  80.   int get_the_mouse9()
  81.     {
  82.       /* If we choose with the mouse */
  83.       /*  Only available for menu 1  */
  84.       if((ym>0)&&(ym<3)){
  85.         /* We clicked on the first line, certainly */
  86.         /* To change of menu.                      */
  87.        menu0=get_the_mouse0();    return(-2);
  88.       }
  89.       if((xm>62)&&(xm<79)){
  90.     if(ym==3){
  91.           /* Printer Choice */
  92.       menu9=1;                   return(1);
  93.     }
  94.     if(ym==4){
  95.           /* available */
  96.       menu9=2;                     return(1);
  97.     }
  98.     if(ym==5){
  99.           /* Choice of the 5 colours for the programs */
  100.       menu9=3;                     return(1);
  101.     }
  102.     if(ym==6){
  103.           /* Sound Yes / No */
  104.       menu9=4;                     return(1);
  105.     }
  106.     if(ym==7){
  107.           /* Access path to the files used by the programs /*
  108.       menu9=5;                     return(1);
  109.     }
  110.     if(ym==8){
  111.           /* Access path to the working file */
  112.       menu9=6;                     return(1);
  113.     }
  114.     if(ym==9){
  115.           /* Access path to the recording files */
  116.       menu9=7;                     return(1);
  117.     }
  118.     if(ym==10){
  119.           /* Re-create the file HELP.FIC from HELP.TXT */
  120.       menu9=8;                     return(1);
  121.     }
  122.     if(ym==11){
  123.           /* Display free space on the current drive */
  124.       menu9=9;                     return(1);
  125.     }
  126.     if(ym==12){
  127.           /* Display free memory */
  128.       menu9=10;                    return(1);
  129.     }
  130.       }
  131.       /* If we clicked outside the menu zone            */
  132.       /* we want to erase the menu and return to menu 0 */
  133.       /*  */
  134.       menu0=0;                         return(-2);
  135.     }
  136.  /*---------------------*
  137.   * GET KEYBOARD INPUT9 *
  138.   *---------------------*/
  139.   int get_keyboard_input9()
  140.     {
  141.       /* Standard keyboard keys */
  142.       if(c1==27){
  143.         /* <Esc> we want to go back to menu0 */
  144.     menu0=0;                       return(-2);
  145.       }
  146.       if(c1==13){
  147.         /* <Enter> execute the command */
  148.     return(1);
  149.       }
  150.       if((c1==80)||(c1==112)){
  151.         /* <P> <p> Printer choice */
  152.     menu9=1;                       return(1);
  153.       }
  154. /*    if((c1==86)||(c1==118)){ */
  155.         /* <V> <v> Video choice */
  156. /*      menu9=2;                       return(1);
  157.       }   */
  158.       if((c1==67)||(c1==99)){
  159.         /* <C> <c> Colours choice */
  160.     menu9=3;                       return(1);
  161.       }
  162.       if((c1==83)||(c1==115)){
  163.         /* <S> <s> Sound Yes/No */
  164.     menu9=4;                       return(1);
  165.       }
  166.       if((c1==89)||(c1==121)){
  167.         /* <Y> <y> Access path to the program files */
  168.     menu9=5;                       return(1);
  169.       }
  170.       if((c1==87)||(c1==119)){
  171.         /* <W> <w> Access path to the working files */
  172.     menu9=6;                       return(1);
  173.       }
  174.       if((c1==82)||(c1==114)){
  175.         /* <R> <r> Access path to the record directory */
  176.     menu9=7;                       return(1);
  177.       }
  178.       if((c1==72)||(c1==104)){
  179.         /* <H> <h> Help file. Redone from help.txt */
  180.     menu9=8;                       return(1);
  181.       }
  182.       if((c1==70)||(c1==102)){
  183.         /* <F> <f> Available on the current drive */
  184.     menu9=9;                       return(1);
  185.       }
  186.       if((c1==77)||(c1==109)){
  187.     /* <M> <m>  */
  188.     menu9=10;                   return(1);
  189.       }
  190.       return(0);
  191.     }
  192.  /*-----------------*
  193.   * SPECIAL DECODE9 *
  194.   *-----------------*/
  195.   int special_decode9()
  196.     {
  197.       /* For the 2-bytes coded keys, this is the second byte */
  198.       if(c1==59){
  199.          /* Function key <F1> = help */
  200.      return(22);
  201.       }
  202.       k=get_special_menu00();
  203.       if(k>0)                          return(-2);
  204.       if(c1==72){
  205.         /* Up arrow */
  206.     if(menu9>1)                    menu9--;
  207.     else                           menu9=10;
  208.     return(0);
  209.       }
  210.       if(c1==80){
  211.         /* Down arrow */
  212.     if(menu9<10)                   menu9++;
  213.     else                           menu9=1;
  214.     return(0);
  215.       }
  216.       return(0);
  217.     }
  218.  /*--------------*
  219.   * MENU CHOICE9 *
  220.   *--------------*/
  221.   int menu_choice9()
  222.     {
  223.       /* We do nothing until a key is pressed                */
  224.       /* or we pressed a mouse button.                       */
  225.       /* We use the 'l' return to test if the key pressed    */
  226.       /* or the mouse choice is one we are waiting for       */
  227.       /* else we wait a valid key                            */
  228.       /* Notice that Up and Down arrows only move the cursor */
  229.       /* and we need to confirm it with <Enter>              */
  230.       while(1){
  231.     l=0;
  232.     if(kbhit()){
  233.           /* If we pressed a key */
  234.       c1=getch();
  235.       if(c1>0){
  236.             t=get_keyboard_input9();     break;
  237.       }
  238.       else{
  239.             /* Key coded on 2 bytes */
  240.         c1=getch();
  241.             t=special_decode9();        break;
  242.       }
  243.     }
  244.         /* Else we test the mouse */
  245.         get_mouse_state();
  246.     if(bm==1){
  247.           /* We pressed a mouse button */
  248.           t=get_the_mouse9();     break;
  249.     }
  250.       }
  251.       return(t);
  252.     }
  253.  /*--------------------*
  254.   * DISPLAY MENU LINE9 *
  255.   *--------------------*/
  256.   void display_menu_line9()
  257.     {
  258.       /* First we display the chosen menu0 */
  259.       textattr(colour5);
  260.       gotoxy(66,1);                    cputs(" Config. ");
  261.       /* Same thing for the selected line */
  262.       if(menu9==1){
  263.         gotoxy(63,3);                  cputs(" Printer        ");
  264.       }
  265.       if(menu9==2){
  266.     gotoxy(63,4);                      cputs("                ");
  267.       }
  268.       if(menu9==3){
  269.         gotoxy(63,5);                  cputs(" Colours choice ");
  270.       }
  271.       if(menu9==4){
  272.         gotoxy(63,6);                  cputs(" Sound =        ");
  273.         /* We display too if the sound is activated or not */
  274.         gotoxy(72,6);
  275.         if(soundvar==1)                     cputs(" yes ");
  276.         else                           cputs(" no ");
  277.       }
  278.       if(menu9==5){
  279.         gotoxy(63,7);                  cputs(" sYstem dir.    ");
  280.       }
  281.       if(menu9==6){
  282.         gotoxy(63,8);                  cputs(" Working dir.   ");
  283.       }
  284.       if(menu9==7){
  285.         gotoxy(63,9);                  cputs(" Recording dir. ");
  286.       }
  287.       if(menu9==8){
  288.         gotoxy(63,10);                 cputs(" Help file      ");
  289.       }
  290.       if(menu9==9){
  291.         gotoxy(63,11);                 cputs(" Free disk space");
  292.       }
  293.       if(menu9==10){
  294.         gotoxy(63,12);                 cputs(" avail. Memory  ");
  295.       }
  296.     }
  297.  /*----------------------*
  298.   * DISPLAY KEY LETTER 9 *
  299.   *----------------------*/
  300.   void display_key_letter9()
  301.     {
  302.       textattr(116);
  303.       gotoxy(64,3);                   cputs("P");
  304.       gotoxy(64,4);                   cputs(" ");
  305.       gotoxy(64,5);                   cputs("C");
  306.       gotoxy(64,6);                   cputs("S");
  307.       gotoxy(65,7);                   cputs("Y");
  308.       gotoxy(64,8);                   cputs("W");
  309.       gotoxy(64,9);                   cputs("R");
  310.       gotoxy(64,10);                  cputs("H");
  311.       gotoxy(64,11);                  cputs("F");
  312.       gotoxy(71,12);                  cputs("M");
  313.       /* We display if sound is activated or not */
  314.       gotoxy(72,6);
  315.       if(soundvar==1)                       cputs(" yes ");
  316.       else                             cputs(" no  ");
  317.     }
  318.  /*---------------*
  319.   * DISPLAY MENU9 *
  320.   *---------------*/
  321.   void display_menu9()
  322.     {
  323.       /* To avoid the trace of the previous mouse position */
  324.       /* we hide it during the display,                    */
  325.       /* and show it when the line has been displayed.     */
  326.       hide_the_mouse();               textattr(colour2);
  327.       gotoxy(61,2);                    cputs(" ┌────────────────┐ ");
  328.       gotoxy(61,3);                    cputs(" │ Printer        │ ");
  329.       gotoxy(61,4);                    cputs(" │                │ ");
  330.       gotoxy(61,5);                    cputs(" │ Colours choice │ ");
  331.       gotoxy(61,6);                    cputs(" │ Sound =        │ ");
  332.       gotoxy(61,7);                    cputs(" │ sYstem dir.    │ ");
  333.       gotoxy(61,8);                    cputs(" │ Working dir.   │ ");
  334.       gotoxy(61,9);                    cputs(" │ Recording dir. │ ");
  335.       gotoxy(61,10);                   cputs(" │ Help file      │ ");
  336.       gotoxy(61,11);                   cputs(" │ Free disk space│ ");
  337.       gotoxy(61,12);                   cputs(" │ avail. Memory  │ ");
  338.       gotoxy(61,13);                   cputs(" └────────────────┘ ");
  339.       display_key_letter9();           display_menu_line9();
  340.       show_the_mouse();
  341.     }
  342.  /*----------------*
  343.   * MENU MANAGER 9 *
  344.   *----------------*/
  345.   int menu_manager9()
  346.     {
  347.       restore_screen();                return1=0;
  348.       while(1){
  349.         display_menu9();               return1=menu_choice9();
  350.         if(return1==-2)                return(-2);
  351.         if(return1==-1)                return(-1);
  352.         if(return1==22)                choice_display_help9();
  353.         display_menu9();
  354.         if(return1==1){
  355.           /* We execute the selected function */
  356.       if(menu9==1){
  357.             /* Printer choice */
  358.             printer_choice();
  359.       }
  360.       if(menu9==2){
  361.             /* available */
  362.  
  363.       }
  364.       if(menu9==3){
  365.             /* Colours choice */
  366.             colour_choice();
  367.       }
  368.       if(menu9==4){
  369.             /* Toggle sound */
  370.             soundvar++;
  371.             if(soundvar>1)                  soundvar=0;
  372.       }
  373.       if(menu9==5){
  374.             /* Access path to the program and the config */
  375.             define_the_system_directory();
  376.       }
  377.       if(menu9==6){
  378.             /* define the working directory (users files) */
  379.             define_the_work_directory();
  380.       }
  381.       if(menu9==7){
  382.             /* define the recording path */
  383.             define_recording_directory();
  384.       }
  385.       if(menu9==8){
  386.             /* help file, change the file HELP.TXT to HELP.FIC */
  387.             /* by cutting the RC and LF */
  388.             create_on_line_help_file();
  389.       }
  390.       if(menu9==9){
  391.             /* display the free space on the drive */
  392.             display_free_space_on_disk();
  393.       }
  394.       if(menu9==10){
  395.             /* display the free memory */
  396.             display_free_memory();
  397.       }
  398.     }
  399.       }
  400.     }
  401. /* End of the Module *//*----------------*/
  402.